package com.lc.rocketmq.mq;

import com.alibaba.fastjson.JSONObject;
import com.lc.rocketmq.common.Constants;
import com.lc.rocketmq.service.SeckillConsumeService;
import com.lc.rocketmq.vo.SeckillVo;
import com.lc.rocketmq.vo.WaitingPayVo;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author liuc
 * @date 2021/8/21
 * @description
 **/
@Component
@RocketMQMessageListener(consumerGroup = "paying_consumer_group", topic = Constants.TOPIC_WAITING_PAY)
public class WaitingPayConsumer implements RocketMQListener<String> {

    @Autowired
    private SeckillConsumeService seckillConsumeService;

    @Override
    public void onMessage(String s) {
        WaitingPayVo payVo = JSONObject.parseObject(s, WaitingPayVo.class);
        seckillConsumeService.payTimeout(payVo);
    }
}
